<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />

		<link rel="stylesheet" type="text/css" href="a.css">
		<title>
		</title>
	</head>
	<body>	
	<table border="2px" cellspacing="0" width="90%">
		<tr>
			<th style="height: 85px;font-size: 25px">直圈锻重计算</th>
		</tr>
		<tr>
				<td><span style="color: red">料圆直径--></span><input placeholder="料圆直径"  name="materireSize" id="materySize"></td>
		</tr>
		<tr>
			<td><span style="color: red">锻件外径--><input placeholder="锻件外径"   name="pro_DD" id="pro_DD"></span>
			</td>
		</tr>
		<tr>
			<td><span style="color: red">锻件内径--><input placeholder="锻件内径"  name="pro_dd" id="pro_dd"></span>
			</td>
		</tr>
		<tr>
			<td><span style="color: red">锻件高度--><input placeholder="锻件高度"  name="pro_HH" id="pro_HH"></span>
			</td>
		</tr>
		<tr>
			<td><span style="color: red">火耗系数--></span><input placeholder="火耗系数"  name="huohao" id="huohao" value="1.06"></td>
		</tr>
		<tr>
			<td><span style="color: red">钢材系数--></span><input placeholder="钢材系数"   id="materyNumber" value="0.00000617"></td>
		</tr>

	</table> 


	
	<div id="dataContent">
		<div>
			<span id="re">锻件参数：</span>
			<div id="retaiData">
				<span style="width: 49%" id="pro_meight">锻件重量：0Kg</span>
				<span  style="width: 49%" id="pro_liao">料芯重量：0Kg</span>	
			</div>

			<div id="retaiData">
				
				<span  style="width: 49%" id="pro_xialiao_meight">下料重量：0Kg</span>
				<span  style="width: 49%" id="pro_xiao">消耗重量：0Kg</span>
			</div>

			<div id="retaiData">
				
				<span  style="width: 49%" id="materyLength">下料长度：0</span>
				<span  style="width: 49%" id="changjingbi">长径比：0</span>
			</div>

		</div>

		
			<div id="buttons">
				<button id="doTata_button" onclick="jisuan(this,'meight')" >计算</button>

				<button id="clear_btton" onclick="clears(this,'meight')">清除</button>

			</div>

			<!--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-->

	<div>
			<table border="2px" cellspacing="0" width="90%" style="margin-top: 150px">
			<tr>
				<th style="height: 85px;font-size: 25px">下料计算</th>
			</tr>

			<tr>
				<td><span style="color: red">料圆直径--></span><input placeholder="料圆直径"  name="materireSize" id="materireSize"></td>
			</tr>
			<tr>
				<td><span style="color: red">下料重量--></span><input placeholder="实际下料重量"   id="materyMeight"></td>
			</tr>
			<tr>
			<td><span style="color: red">钢材系数--></span><input placeholder="钢材系数"   id="materyNumbers" value="0.00000617"></td>
			</tr>

			</table> 

		<div style="margin-top:40px;">
			<span id="re">下料参数：</span>
			<div id="retaiData">
				<span id="mater_length">下料长度：0</span>

				<span id="leng_bi">长径比值：0</span>
				
			</div>
		</div>

			<div id="two" style="height: 60px;">
				<button id="doTata_button" onclick="jisuan(this,'length')">计算</button>

				<button id="clear_btton" onclick="clears(this,'length')">清除</button>

			</div>


		</div>

		<table border="2px" cellspacing="0" width="90%" style="margin-top: 150px">
			<tr>
				<th style="height: 85px;font-size: 25px">热态计算</th>
			</tr>
			<tr>
				<td><span style="color: red">锻件外径--><input placeholder="锻件外径"   name="re_pro_DD" id="re_pro_DD"></span>
				</td>
			</tr>
			<tr>
				<td><span style="color: red">锻件内径--><input placeholder="锻件内径"  name="re_pro_dd" id="re_pro_dd"></span>
				</td>
			</tr>
			<tr>
				<td><span style="color: red">锻件高度--><input placeholder="锻件高度"  name="re_pro_HH" id="re_pro_HH"></span>
				</td>
			</tr>
			<tr>
				<td><span style="color: red">热态系数--></span><input placeholder="热态系数"  name="retaixishu" id="retaixishu" ></td>
			</tr>
	
		</table> 


		<div>
			<span id="re">热态值：</span>
			<div id="retaiData">
				<span id="pro_DD_re">外径：热&nbsp(ø)</span>
				<span id="pro_dd_re">内径：热&nbsp(ø)</span>
				<span id="pro_HH_re">高度：热&nbsp()</span>
			</div>
		</div>
		<div id="three" style="height: 60px;">
				<button id="doTata_button" onclick="jisuan(this,'retai')">计算</button>

				<button id="clear_btton" onclick="clears(this,'retai')">清除</button>

		</div>
		
	</div>



	<script>

		function jisuan(obj,name){

		switch(name){
			case 'meight':getMeight();
			break;
			case 'length':getLength();
			break;
			case 'retai':getReTai();
			break;
		}


	function getMeight(){

		 var product={
			pro_DD:getObject("pro_DD").value,//锻件外径
			pro_dd:getObject("pro_dd").value,//锻件内径
			pro_HH:getObject("pro_HH").value,//锻件高度
			huohao:getObject("huohao").value,//火耗
			materyNumber:getObject("materyNumber").value,
			materySize:getObject("materySize").value

		}

		//算 锻件重量
		
		product.pro_meight=((product.pro_DD*product.pro_DD-product.pro_dd*product.pro_dd)*product.materyNumber*product.pro_HH).toFixed(1);

		//算料芯重量
		
		product.pro_liao=(product.pro_meight*0.03).toFixed(1);

		//算 下料重量

		product.pro_xialiao_meight=(product.pro_meight*product.huohao).toFixed(1);

		//算下料长度
		
		product.materyLength=(product.pro_xialiao_meight/product.materySize/product.materySize/product.materyNumber).toFixed(1);

		//算长径比
		
		product.changjingbi=(product.materyLength/product.materySize).toFixed(2);

		//算消耗
		
		product.pro_xiao=(product.pro_xialiao_meight*1.03).toFixed(1);

		//设置锻件重量
		
		getObject("pro_meight").textContent="锻件重量："+product.pro_meight+"Kg";

		//设置料芯重量
		getObject("pro_liao").textContent="料芯重量："+product.pro_liao+"Kg";

		//设置下料重量
		
		getObject("pro_xialiao_meight").textContent="下料重量："+product.pro_xialiao_meight+" Kg";

		//设置下料长度
		
		getObject("materyLength").textContent="下料长度："+product.materyLength;

		//设置长径比
		
		getObject("changjingbi").textContent="长径比："+product.changjingbi;

		//设置消耗重量
		
		getObject("pro_xiao").textContent="消耗重量："+product.pro_xiao+"Kg";

	}

	 //获取下料的长度
	function getLength(){

		 var product={
			materireSize:getObject("materireSize").value,
			materyMeight:getObject("materyMeight").value,
			materyNumbers:getObject("materyNumbers").value
		}

		product.pro_length=(product.materyMeight/product.materireSize/product.materireSize/product.materyNumbers).toFixed(1);

		getObject("mater_length").textContent="下料长度："+product.pro_length;

		product.leng_bi=(product.pro_length/product.materireSize).toFixed(2);

		getObject("leng_bi").textContent="长径比："+product.leng_bi;

	}
	//获取热态尺寸
	function getReTai(){
		var product={
			retaixishu:getObject("retaixishu").value
		}
		product.re_pro_DD=(getObject("re_pro_DD").value*product.retaixishu).toFixed(1);
		product.re_pro_dd=(getObject("re_pro_dd").value*product.retaixishu).toFixed(1);
		product.re_pro_HH=(getObject("re_pro_HH").value*product.retaixishu).toFixed(1);



		getObject("pro_DD_re").innerHTML="外径：热&nbsp(ø"+product.re_pro_DD+")";
		getObject("pro_dd_re").innerHTML="内径：热&nbsp(ø"+product.re_pro_dd+")";
		getObject("pro_HH_re").innerHTML="高度：热&nbsp("+product.re_pro_HH+")";

	}


	}

	//清除
	
	function clears(obj,name){
		switch(name){
			case 'meight':
			clearInputContent("pro_DD");
			clearInputContent("pro_dd");
			clearInputContent("pro_HH");
			break;
			case 'length':
			clearInputContent("materireSize");
			clearInputContent("materyMeight");
			break;
			case 'retai':
			clearInputContent("re_pro_DD");
			clearInputContent("re_pro_HH");
			clearInputContent("re_pro_dd");
			break;
		}


	}

	function  clearInputContent(id){
		document.getElementById(id).value=""
	}
	
		
/*获取input元素*/

		function getObject(id){
			var obj = document.getElementById(id);

			return obj;
		}

	</script>

	</body>
</html>